package 力扣日常刷题.木23一月.第08天308;

/**
 * @author 帅小伙
 * @date 2022/3/8
 * @description
 */
public class Demo22二维数组中的查找 {

    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        if(matrix == null || matrix.length == 0 || matrix[0].length == 0) return false;

        int x = matrix.length,y = matrix[0].length - 1;
        int curX = 0,curY = y;

        while(curX < x && curY >= 0){
            if(matrix[curX][curY] == target) return true;
            else if(matrix[curX][curY] > target)curY--;
            else curX++;
        }

        return false;


    }

}
